<?php
/* SVN FILE: $Id: ajaxed_controller.php 108 2007-04-15 22:50:29Z Andy $ */

/**
 * Short description for file.php.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Copyright (c), Andy Dawson
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright    Copyright (c) 2007, Andy Dawson
 * @package      noswad
 * @subpackage   noswad.app.plugins.pagination.controllers
 * @since        Noswad site version 3
 * @todo         TODO Edit this block
 * @version      $Revision: 108 $
 * @created      26/01/2007
 * @modifiedby   $LastChangedBy$
 * @lastmodified $Date: 2007-04-16 00:50:29 +0200 (lun, 16 abr 2007) $
 * @license      http://www.opensource.org/licenses/mit-license.php The MIT License
 */

/**
 * Short description for Class
 *
 * Long descrption of Class
 */

/**
 * Description for var
 *
 * @var type
 * @access public/private/protected
 */

/**
 * Description for method
 *
 * @param type $name description
 * @return type description
 */
 class AjaxedController extends PaginationAppController {
	var $menuActionsExclude = array ('old_style_index','custom_index','search_results','extra_get_params','extra_params','no_limits','results','random');
	var $components = array ('Pagination','RequestHandler');
	var $helpers = array('Pagination','Ajax');

	var $name = 'Ajaxed'; // required for PHP4 installs

	function seeing_double () {
		$this->_addFlash('This page will only work if AJAX is available, to make it work without AJAX is possible but would require customization of the Pagination Helper/Component.');
		$this->render('seeing_double');
	}

	function random() {
		$random = intval(rand());
		list($order,$limit,$page) = $this->Pagination->init(null,null,array('ajaxDivUpdate'=>'div'.$random,'url'=>'/Pagination/Ajaxed/random'));
		$this->data = $this->{$this->modelClass}->findAll(null, null, $order, $limit, $page);
		$this->set('randomId',$random);
		$this->render('random');
	}

	function _defineContextMenus() {
		return array (
			'Actions' => array (
				'data' => array (
					array (
						'title' => 'normal',
						'url' => "/{$this->plugin}/{$this->name}/"
					),
					array (
						'title' => 'Seeing Double',
						'url' => "/{$this->plugin}/{$this->name}/seeing_double"
					)
				)
			)
		);
	}
}
?>